/**
 * Created by xuelian on 2018/3/26.
 */
class BuycardRecordItem extends ComponentEx {

    private lab_time: eui.Label;
    private lab_desc: eui.Label;
    private lab_cost: eui.Label;
    private lab_total: eui.Label;

    constructor() {
        super();
        this.skinName = "BuycardRecordItemSkin";
    }

    childrenCreated() {
        super.childrenCreated();

    }


    update(data: any) {
        if (!data) return;

        this.data = data;

        this.lab_time.text = "" + StringUtils.getYTFByTimestamp(data.time * 1000) + " " + StringUtils.getHMSByTimestamp(data.time * 1000);

        this.lab_desc.text = this.getFomat(data.operate) + (data.hasOwnProperty('roomid') ? "(" + data.roomid + ")" : '');

        this.lab_cost.text = (data.real_card_num >= 0 ? '+' : '-') + StringUtils.getNumberStr(Math.abs(data.real_card_num)) + "张房卡";
        this.lab_cost.textColor = data.real_card_num > 0 ? 0x3889AB : 0xFE0101;

        this.lab_total.text = "剩余" + StringUtils.getNumberStr(data.card_left) + "张";
    }

    getFomat(operate: number) {
        let desc: string = '';
        switch (operate) {
            case 1:
                desc = "充值房卡";
                break;
            case 2:
                desc = "撤销房卡";
                break;
            case 3:
                desc = "创建俱乐部房间";
                break;
            case 4:
                desc = "解散俱乐部房间";
                break;
            case 5:
                desc = "创建房间";
                break;
            case 6:
                desc = "加入AA制房间";
                break;
            case 7:
                desc = "解散房间";
                break;
            case 8:
                desc = "解散AA制房间";
                break;
            case 9:
                desc = "活动奖励";
                break;
            case 10:
                desc = "离开AA制房间";
                break;
            case 11:
                desc = "创建AA制房间";
                break;
        }
        return desc;
    }
}